package com.aboo.dao.callback;

import java.sql.SQLException;
import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.aboo.parameter.ParameterSetHelper;

public class FindCallbackHandler implements HibernateCallback {

	private String hqlStr;
	private Map<String, Object> params;
	
	public FindCallbackHandler(String hqlStr, Map<String, Object> params) {
		this.hqlStr = hqlStr;
		this.params = params;
	}
	
	public Object doInHibernate(Session s) throws HibernateException,
			SQLException {
		Query query = s.createQuery(this.hqlStr);
		ParameterSetHelper.setParameter(query, this.params);
		return query.list();
	}

}
